package xxl.ioc.reflection 
{
	import flash.utils.getDefinitionByName;
	import flash.utils.getQualifiedClassName;
	import flash.utils.Proxy;
	/**
	 * ...
	 * @author XXL
	 */
	public class ReflectorBase 
	{
		
		public function ReflectorBase() 
		{
			
		}
		
		public function getClass(value:Object):Class
		{
			if (value is Proxy || value is Number || value is XML || value is XMLList)
			{
				return Class(getDefinitionByName(getQualifiedClassName(value)));
			}
			return value.constructor;
		}
		
		public function getFQCN(value:*, replaceColons:Boolean = false):String
		{
			var fqcn:String;
			if (value is String)
			{
				fqcn = value;
				if (!replaceColons && fqcn.indexOf("::") == -1)
				{
					const lastDotIndex:int = fqcn.lastIndexOf(".");
					if (lastDotIndex == -1)
					{
						return fqcn;
					}
					return fqcn.substring(0, lastDotIndex) + "::" + fqcn.substring(lastDotIndex + 1);
				}
			}
			else
			{
				fqcn = getQualifiedClassName(value);
			}
			return replaceColons ? fqcn.replace("::", "."):fqcn;
		}
		
	}

}